package com.ambulance.project.biz.controller.treatter;

import com.ambulance.common.utils.ResultMapUtil;
import com.ambulance.framework.web.domain.AjaxResult;
import com.ambulance.project.biz.entity.Dispatch;
import com.ambulance.project.biz.entity.DispatchCase;
import com.ambulance.project.biz.entity.Patient;
import com.ambulance.project.biz.service.DispatchCaseService;
import com.ambulance.project.biz.service.DispatchService;
import com.ambulance.project.biz.service.PatientService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @Author RXL
 * @Date 2020/5/25 11:49
 * @Version 1.0
 */
@Api(tags = {"会诊子系统终端-患者信息相关接口"})
@RestController
@RequestMapping(value = "/treat/patient/v1", method = RequestMethod.POST)
public class TreatDispatchCase {

    @Autowired
    private DispatchCaseService dispatchCaseService;
    @Autowired
    private PatientService patientService;
    @Autowired
    private DispatchService dispatchService;

    @RequestMapping(value = "/120info")
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "调度编号", dataType = "int"),
    })
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数不正确"),
            @ApiResponse(code = 404, message = "404请求路径不正确"),
            @ApiResponse(code = 200, response = DispatchCase.class, message = "响应")
    })
    public Object get120Info(@RequestParam(value = "dispatchId") Integer dispatchId) {
        final Dispatch dispatchServiceById = dispatchService.getById(dispatchId);
        final Patient patientOne = patientService.getOne(new QueryWrapper<Patient>().eq("patientId", dispatchServiceById.getPatientID()));
        String[] param = {"name", "phone", "sex", "age", "patient_local", "patient_card", "hospital", "major_case"};
        return AjaxResult.success(ResultMapUtil.customerObjField(patientOne, param));
    }


    @RequestMapping(value = "/patientInfo")
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "调度编号", dataType = "int"),
    })
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数不正确"),
            @ApiResponse(code = 404, message = "404请求路径不正确"),
            @ApiResponse(code = 200, response = DispatchCase.class, message = "响应")
    })
    public Object getPatientInfo(@RequestParam(value = "dispatchId") Integer dispatchId) {
        final DispatchCase dispatchID = dispatchCaseService.getOne(new QueryWrapper<DispatchCase>().eq("dispatchID", dispatchId));
        String[] param = {"patient_name", "patient_sex", "patient_age", "patient_mobile", "patient_address"};
        return AjaxResult.success(ResultMapUtil.customerObjField(dispatchID, param));
    }


    @RequestMapping(value = "/DiagnoseInfo")
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "调度编号", dataType = "int"),
    })
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数不正确"),
            @ApiResponse(code = 404, message = "404请求路径不正确"),
            @ApiResponse(code = 200, response = DispatchCase.class, message = "响应")
    })
    public Object getDiagnoseInfo(@RequestParam(value = "dispatchId") Integer dispatchId) {
        final DispatchCase dispatchID = dispatchCaseService.getOne(new QueryWrapper<DispatchCase>().eq("dispatchID", dispatchId));
        String[] param = {"major_case", "base_help", "treatment_record", "medicine_sensitive", "nhiss_score", "gcs_score", "medicine", "hospital"};
        return AjaxResult.success(ResultMapUtil.customerObjField(dispatchID, param));
    }

}
